﻿@using Wicresoft.UnifyShow.Business;
@{
    List<DeviceAndAlertCountModel> alerts = (List<DeviceAndAlertCountModel>)ViewData["alerts"];
    //List<SiteAndCountModel> devices = (List<SiteAndCountModel>)ViewData["devices"];
    List<UserAndSiteModel> sitesMe = (List<UserAndSiteModel>)ViewData["SitesMe"];
    List<string> sitesAlias = sitesMe.Select(o => o.SiteAlias).ToList(); 
}
<div class="index_pt_bg">
    <table class="ContactTB  talbe_gray" width="100%" height="160" border="0" cellpadding="0" cellspacing="0">
        <thead>
            <tr class="ContactTH" >
                <td height="55" class="altrow">
                    地市
                </td>
                <td height="55" class="altrow">
                    类型
                </td>
                @foreach (string type in GlobalHelper.DeviceTypes)
                { 
                    <td height="55" class="altrow">@type
                    </td>
                }
            </tr>
        </thead>
        <tbody>
            @foreach (string item in sitesAlias)
            {

                <tr>
                    <td rowspan="2">
                        @item
                    </td>
                    <td>
                        数量
                    </td>
                    @foreach (string type in GlobalHelper.DeviceTypes)
                    {
                        <td height="25">
                            @alerts.Where(o => o.SiteName == item && o.Type == type).Count()
                        </td>
                    }
                </tr>
                <tr>
                    <td>
                        健康度
                    </td>
                    @foreach (string type in GlobalHelper.DeviceTypes)
                    {
                        decimal alertcount = alerts.Where(o => o.SiteName == item && o.Type == type && o.AlertCount > 0).Count();                                                               
                        <td height="25">
                            @if (alertcount > 0)
                            { <i class="right_title_imptant_red ui-icons">@alertcount</i>}
                            else
                            {<i class="right_title_imptant_green ui-icons">@alertcount</i>}
                        </td>
                    }
                </tr>
            }
        </tbody>
    </table>
</div>
